import request from '@/config/axios'

export interface WeComApiConfigVO {
  id: number
  appCorpId: string
  appAgentId: string
  appSecret: string
  appAesKey: string
  contactsSecret: string
  contactsToken: string
  contactsAesKey: string
  customerSecret: string
  customerToken: string
  customerAesKey: string
  kfSecret: string
  kfToken: string
  kfAesKey: string
}

// 查询企业参数配置列表
export const getWeComApiConfigPage = async (params) => {
  return await request.get({ url: `/wecom/we-com-api-config/page`, params })
}

// 查询企业参数配置
export const getWeComApiConfig = async (id: number) => {
  return await request.get({ url: `/wecom/we-com-api-config/get` })
}

// 新增企业参数配置
export const createWeComApiConfig = async (data: WeComApiConfigVO) => {
  return await request.post({ url: `/wecom/we-com-api-config/create`, data })
}

// 修改企业参数配置
export const updateWeComApiConfig = async (data: WeComApiConfigVO) => {
  return await request.put({ url: `/wecom/we-com-api-config/update`, data })
}

// 删除企业参数配置
export const deleteWeComApiConfig = async (id: number) => {
  return await request.delete({ url: `/wecom/we-com-api-config/delete?id=` + id })
}

// 导出企业参数配置 Excel
export const exportWeComApiConfig = async (params) => {
  return await request.download({ url: `/wecom/we-com-api-config/export-excel`, params })
}

// 保存应用配置
export const saveAppConfig = async (data: WeComApiConfigVO) => {
  return await request.post({ url: `/wecom/we-com-api-config/save-app-config`, data })
}

// 保存应用主页配置
export const saveAppHomeConfig = async (data: WeComApiConfigVO) => {
  return await request.post({ url: `/wecom/we-com-api-config/save-app-config`, data })
}

// 更新企业微信通讯录配置
export const saveContactsConfig = async (data: WeComApiConfigVO) => {
  return await request.post({ url: `/wecom/we-com-api-config/save-contacts-config`, data })
}

// 更新企业微信客户联系配置
export const saveCustomerConfig = async (data: WeComApiConfigVO) => {
  return await request.post({ url: `/wecom/we-com-api-config/save-customer-config`, data })
}

// 更新企业微信客服配置
export const saveKfConfig = async (data: WeComApiConfigVO) => {
  return await request.post({ url: `/wecom/we-com-api-config/save-kf-config`, data })
}

// 获取sapi-signature
export const getJsapiSignature = async (data) => {
  return await request.post({ url: `/wecom/we-com-api-config/get-jsapi-signature`, data })
}
// 客户消息列表
export const listByCustomer = async (params) => {
  return await request.get({ url: `/wecom/we-msg-record/list-by-customer`, params })
}
// 客户群消息列表
export const listByChat = async (params) => {
  return await request.get({ url: `/wecom/we-chat-msg-record/list-by-chat`, params })
}
//根据企微员工获取客户列表
export const listByUser = async (params) => {
  return await request.get({ url: `/wecom/we-customer/get-list-by-user`, params })
}
// 校验企业微信登录是否过期
export const userCallback = async (params) => {
  return await request.get({ url: `/wecom/user/auth/callback`, params })
}
// 获取聊天工具栏页面地址
export const getChatToolPage = async () => {
  return await request.get({ url: `/wecom/we-com-api-config/get-chat-tool-page` })
}
// 会话记录保存天数
export const editMsgSaveDay = async (data) => {
  return await request.post({ url: `/wecom/we-com-api-config/edit-msg-save-day`, data })
}
